// Shallow copy and deep copy problem

#include <iostream>
#include <cstring>
using namespace std;

class String {
	public:
		String( const char* psz="" ):m_psz( new char[strlen(psz)+1] ) {
			strcpy( m_psz, psz);
		}
		~String( ) {
			delete[] this->m_psz;
		}
		String( const String& that ):m_psz( new char[strlen(that.m_psz)+1]) {
			strcpy( m_psz, that.m_psz );
		}
		char* c_str( ) { return m_psz; }
	private:
		char* m_psz;
};

// designer
// ------------------------------------------------------------------
// user

int main( void ) { 
	String s1( "hello" );
	cout << "s1 : " << s1.c_str() << endl;
	cout << "address : " << (void*)s1.c_str() << endl;

	Sting s2( s1 ) ;
	cout << "s2 : " << s1.c_str() << endl;
	cout << "address : " << (void*)s2.c_str() << endl;

	return 0;
}

